<?php
ob_start();
header("Content-Type:text/xml; charset=utf-8");
$db = $_REQUEST['db'];
print("<xml>\n");
try {
    // MySQLサーバへ接続
    $pdo = new PDO("pgsql:host=localhost; dbname=$db",
                   "postgres", "postgres");
    $stmt = $pdo->query("select * from geometry_columns order by f_table_name");

    while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
    	print("<geometryColumn db=\"" . $db . "\">\n");
		foreach($row as $k => $value) {
			print("<" . $k . ">" . $value . "</" . $k . ">\n");
		}
    	print("</geometryColumn>\n");
    }
} catch(PDOException $e){
    var_dump($e->getMessage());
}
print("</xml>");

$cLength = ob_get_length();

header("Content-Length:" . $cLength);
ob_end_flush();
// 切断
$pdo = null;

?>
